<template>
  <!-- 宿舍入住信息页面 -->
  <div class="app-container">
    <!-- 搜索 -->
    <searchForm
      :formOptions="formOptions"
      @onSearch="onSearch"
      @onReset="onReset"
      v-show="showSearch"
      :formLabelWidth="formLabelWidth"
    />
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table :data="tableData">
      <el-table-column prop="registerCode" label="注册号"> </el-table-column>
      <el-table-column prop="studentName" label="姓名"> </el-table-column>
      <el-table-column prop="sex" label="性别"> </el-table-column>
      <el-table-column prop="houseNo" label="公寓楼"> </el-table-column>
      <el-table-column prop="roomNo" label="房间号"> </el-table-column>
      <el-table-column prop="bedNo" label="床位号"> </el-table-column>
      <el-table-column prop="roomType" label="房间类型"> 
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_room_type" :value="scope.row.roomType"></dict-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="name" label="房间朝向"> </el-table-column> -->
      <el-table-column prop="bedNo" label="床位号"> </el-table-column>
      <el-table-column prop="studentType" label="标记">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.basic_student_mark" :value="scope.row.studentType"></dict-tag>
        </template>
         </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {bedList} from '@/api/apartment/roomAccommodation'
import { getDicts } from "@/api/system/dict/type";
import searchForm from "@/components/Search/searchForm.vue";
export default {
  components: { searchForm },
  dicts: ["basic_student_mark",'sys_room_type'],
  data() {
    return {
      dutiesList:[],
      formOptions: [
        {
          label: "公寓楼",
          prop: "houseNo",
          element: "el-input",
          placeholder: "请输入公寓楼",
        },
        {
          label: "房间号",
          prop: "roomNo",
          element: "el-input",
          placeholder: "请输入房间号",
        },
        {
          label: "注册号",
          prop: "registerCode",
          element: "el-input",
          placeholder: "请输入注册号",
        },
        {
          label: "床位号",
          prop: "bedNo",
          element: "el-input",
          placeholder: "请输入床位号",
        },
        {
          label: "姓名",
          prop: "studentName",
          element: "el-input",
          placeholder: "请输入姓名",
        },
        {
          label: "标记",
          prop: "studentType",
          element: "el-select",
          options: this.dutiesList ,
          placeholder: "请选择标记",
        },
      ],
      formLabelWidth: "60px",
      tableData: [],
      total: 0,
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
    getDicts("basic_student_mark").then(res => {
      this.formOptions[5].options = res.data.map(item => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"]
        };
      });
    });
  },
  methods: {
    // 获取搜索表单提交的数据
    onSearch(val) {
      // 查询条件和分页数据合并
      this.queryParams = Object.assign(this.queryParams, val);
      this.queryParams.pageNum = 1;
      this.getList();
    },
     // 重置
     onReset(data) {
     
      this.queryParams.pageNum = 1;
      this.queryParams = Object.assign(this.queryParams, data);
      this.getList();
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      bedList(this.queryParams).then(
        (response) => {
          this.tableData = response.rows;
          this.total = response.total;
        }
      );
    },
  },
};
</script>

<style>
</style>